home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-01-28 | 11.4 KB | 339 lines | [TEXT/gamI] |
- Documentation for Gambit v1.51 for Macintosh
- --------------------------------------------
-
- In this documentation, you will find information on the following
- applications:
-
- - Gambit Interpreter
- - Gambit Compiler
- - Gambit Linker
-
- All of these applications run on Mac+/SE/II computers.
-
-
- Gambit Interpreter
- ------------------
-
- The Gambit Interpreter (GSI for short) is a Scheme interpreter that
- can be used to develop and debug Gambit Scheme programs. GSI conforms
- to the IEEE-Scheme standard as well as the R3.99RS report. In
- addition, GSI has the ability to dynamically load object files (i.e.
- files with a .O extension) produced by the Gambit compiler. GSI has a
- minimal debugging environment that supports program interrupt, error
- resume and abort. Gambit v1.51 implements exact arithmetic only
- (including bignums and rationals). Real and complex numbers are not
- available.
-
- When GSI is launched, it grabs the entire memory for its heap (GSI can
- run with as little as 1 Meg of memory). Under Multifinder it is
- possible to limit the amount of memory used by GSI by changing GSI's
- memory requirement information with the finder's <cmd>-I command.
-
- If present, the file "init.scm" is loaded when GSI is launched. This
- file can be used to customize GSI to your own needs.
-
- Most of the interaction with GSI's read-eval-print (REP) loop is done
- through the keyboard. To evaluate an expression, place the caret
- after the end of the expression and press <enter>. This will send the
- expression to the interpreter for evaluation and the result will be
- displayed in the interaction window. In addition, it is possible to
- send arbitrary text to the interpreter by selecting it before pressing
- <enter>. These evaluation mechanisms also work in windows attached to
- files (however the result is always displayed in the interaction
- window). For example, if you are reading this file from GSI, place the
- caret after the closing parenthesis of (* 3 5) and press <enter>. The
- value 15 should be printed on the interaction window.
-
- The tab key can be used to move the caret to the appropriate indentation
- position.
-
- Special keyboard commands are available to interact with the
- interpreter:
-
- - <cmd>-. Interrupts the current computation and starts a new REP loop
- - <cmd>-R Resumes an interrupted computation
- - <cmd>-D Returns to the previous REP loop (also acts as end-of-file)
- - <cmd>-T Returns to the top-most REP loop
-
-
- Here is a transcript of a typical interaction with GSI (comments are
- marked with ";;;" and user input is in bold):
-
- Gambit (v1.51)
-
- Loading "init.scm"
-
- : ®ÏÔ·‰ ¢Ê·„Ù¢© ;;; load "fact.scm" file
- "fact.scm"
-
- : ®Ê·„Ù ¥∞© ;;; try it
- 815915283247897734345611269596115894272000000000
-
- : ®ÙÚ·„Â Ê·„Ù© ;;; lets trace what fact is doing
- fact
-
- : ®Ê·„Ù ±µ©
- |(fact 15)
- | (fact 14)
- | (fact 13)
- | (fact 12)
- | (fact 11)
- | |(fact 10)
- | | (fact 9)
- | | (fact 8)
- | | (fact 7)
- | | (fact 6)
- | | |(fact 5)
- | | | (fact 4)
- | | | (fact 3)
- | | | (fact 2)
- | | | (fact 1)
- | | | <== 1
- | | | <== 2
- | | | <== 6
- | | | <== 24
- | | |<== 120
- | | <== 720
- | | <== 5040
- | | <== 40320
- | | <== 362880
- | |<== 3628800
- | <== 39916800
- | <== 479001600
- | <== 6227020800
- | <== 87178291200
- |<== 1307674368000
- 1307674368000
-
- : ®ÏÔ·‰ ¢È¢© ;;; load "pi.O" file
- How many digits of pi do you want (0 to exit): ∑∞
- 3.1415926535897932384626433832795028841971693993751058209749445923078164
- How many digits of pi do you want (0 to exit): ∞
- "pi.O"
-
- : ®ÒıÂÂÓÛ ∏ £Ù© ;;; oops!, we haven't defined it yet...
-
- *** ERROR, Unbound variable: queens
-
-
- 1: ;;; user typed <cmd>-D here
- : ®ÏÔ·‰ ¢ÒıÂÂÓÛ¢© ;;; load it!
- "queens.O"
-
- : ®ÒıÂÂÓÛ ∏ £Ù©
- (4 2 7 3 6 8 5 1)
- (5 2 4 7 3 8 6 1)
- (3 6 4 2 8 5 7 1)
- (3 5 2 8 6 4 7 1)
- (5 7 1 3 8 6 4 2)
- (4 6 8 3 1 7 5 2)
- (3 6 8 1 4 7 5 2)
- (5 7 4 1 3 8 6 2)
- (5 3 8 4 7 1 6 2)
- (3 6 4 1 8 5 7 2) ;;; user typed <cmd>-. here
-
- *** INTERRUPT
-
-
- 1: ;;; <cmd>-D
- : ®ÏÔ·‰ ¢ÙÚ¢©
- "tree.scm"
-
- : ®ÙÚÂÂ≠‰ÈÛÏ·˘ ®„·ÏÏ≠˜ÈÙË≠ÈÓıÙ≠ÊÈÏ ¢Ê·„ÙÆÛ„Ì¢ Ú·‰©©
- .
- .----------------------.
- . .
- define .-----------------------------.
- . .
- .---. .-----------------------------------.
- . . . .
- fact .--. .----------. ()
- . . . .
- n () if .---------------.
- . .
- .--. .---------------.
- . . . .
- < .--. 1 .--------------------.
- . . . .
- n .--. .--------. ()
- . . . .
- 2 () * .-------------.
- . .
- n .-----------.
- . .
- .-------. ()
- . .
- fact .--------.
- . .
- .--. ()
- . .
- - .--.
- . .
- n .--.
- . .
- 1 ()
- #[undefined]
-
- :
-
-
- Gambit Compiler
- ---------------
-
- The Gambit Compiler (GSC for short) is used to compile a Scheme source
- program into a binary `object file' that can either be loaded by the
- Gambit Interpreter or turned into a full fledged Macintosh application
- with the Gambit Linker.
-
- GSC needs at least 2.5 Megs to run. A larger memory size is recommended
- to compile large Scheme programs. If you do not have enough memory to
- compile a given program, split it into smaller files.
-
- When launched, GSC will pop up a dialog box. It is through this dialog
- box that you specify what file you want to compile and what compilation
- options to use. The first parameter is the filename of the source file
- (you do not have to specify the extension `.scm'). The remaining
- parameters are the compilation options.
-
- These options are accepted by GSC
-
- verbose Generate a trace of the compiler's actions on
- the interaction window.
-
- report Produce global variable usage report on the
- interaction window. Each global variable used in
- the program is listed with 4 flags that indicate if
- the global variable is defined, referenced, mutated
- and called.
-
- asm Produce the assembly language file on <source>.s .
-
- pvm Produce a listing of the PVM code for the program
- on <source>.pvm .
-
- stats Generate code to gather runtime statistics on the
- program. The statistics will be output on the profile
- file when the program is run.
-
-
- In addition to the standard Scheme special forms, the compiler accepts
- the following forms which can appear anywhere a `define' special form
- can appear:
-
- (##declare <decl>...)
-
- See below for the list of accepted declarations.
- The scope of the declaration extends to the end of the body it is in
- or to the end of the program if it is at toplevel.
-
- (##include "prog.scm")
-
- Read the expressions contained in the given file and splice them
- into the program.
-
- (##define-macro (name parm...) <body>)
-
- Define the name as a macro special form which expands into `body'.
- The scope of the declaration extends to the end of the body it is in
- or to the end of the program if it is at toplevel (unless it is
- redefined before).
-
-
- The following declarations are accepted by the compiler:
-
- (<dialect>)
-
- Use the given dialect's semantics. <dialect> can be:
- ieee-scheme, r4rs-scheme or multischeme.
-
- ([not] lambda-lift)
-
- Lambda-lift (or don't lambda-lift) procedures.
-
- (<strategy>)
-
- Select block compilation or separate compilation. In block
- compilation, the compiler can assume that all references to the
- global variables defined in the current program are located in the
- program itself. <strategy> can be: block or separate.
-
- ([not] standard-bindings <var>...)
-
- The given global variables are known (or not known) to be equal
- to the value defined for them in the dialect (all variables defined
- in the standard if none specified).
-
- ([not] extended-bindings <var>...)
-
- The given global variables are known (or not known) to be equal
- to the value defined for them in the runtime system (all variables
- defined in the runtime if none specified).
-
- ([not] safe)
-
- Generate (or don't generate) code that will prevent fatal runtime
- errors. Note that in `safe' mode certain semantic errors will not be
- checked as long as they can't crash the system. For example
- the primitive `char=?' could disregard the type of its arguments in
- `safe' (as well as `not safe') mode.
-
- ([not] intr-checks)
-
- Generate (or don't generate) interrupt checks. Interrupt checks are
- used to signal the need for a garbage collection, to catch user
- interrupts and also to check for stack overflows. Interrupt checking
- should not be turned off casually.
-
- (<number-type> <prim>...)
-
- Numeric arguments and result of specified primitives are known to be
- of the given type (all primitives if none specified).
- <number-type> can be: generic or fixnum.
-
-
- The default declarations used by the compiler are:
-
- (ieee-scheme)
- (lambda-lift)
- (separate)
- (not standard-bindings)
- (not extended-bindings)
- (not safe)
- (intr-checks)
- (generic)
-
- These declarations are compatible with the IEEE-Scheme standard.
- Typically used declarations that enhance performance (at the cost of
- violating the IEEE-Scheme standard) are: (standard-bindings) and
- (fixnum).
-
- The diagnostic messages produced by GSC are printed on the interaction
- window.
-
- The code generated by GSC is very efficient. Speedups of a factor of 100
- over interpreted code are not uncommon.
-
-
- A useful feature of object files is that they can be run by
- double-clicking them. This is essentially equivalent to starting the
- interpreter and loading the given object file (except that the
- "init.scm" file is not loaded and a REP loop is not entered).
- As an example, exit from GSI and double-click the document file "pi.O".
-
-
- Gambit Linker
- -------------
-
- The Gambit Linker is used to build a Macintosh application program
- from a runtime library and an arbitrary number of object files
- produced by the Gambit compiler. The Gambit linker first prompts for
- the runtime library file and then for a set of object files. The name
- of the application is the same as the name of the last object file to
- be linked with its `.O' extension stripped off. For example, if you
- link the library `Runtime' with the object file `pi.O' you will get
- the application `pi' which you can then double-click to run.
-
- When the linked program is launched, the effect is similar to loading
- each of the object files, in sequence, in the interpreter (except that
- the "init.scm" file is not loaded and a REP loop is not entered).
-